package cn.atzxc.qy;


import cn.atzxc.qy.domain.Address;
import cn.atzxc.qy.domain.vo.StudentCategoryHelpVo;
import cn.atzxc.qy.domain.User;
import cn.atzxc.qy.mapper.UserMapper;
import cn.atzxc.qy.service.AddressService;
import cn.atzxc.qy.service.LoginService;
import cn.atzxc.qy.service.StudentCategoryHelpVoService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.List;

@SpringBootTest
public class testMapper1 {
    @Resource
    private UserMapper testMapper1;
    @Autowired
    LoginService loginService;
    @Autowired
    private AddressService addressService;
    @Autowired
    private StudentCategoryHelpVoService studentCategoryHelpVoService;
    @Test
    public void test01() {

        LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(User::getOpenid, "odYa16wVxfgk2UmYBEEjosz_9YQc");

        User user = testMapper1.selectOne(queryWrapper);
        System.out.println(user);
    }
    @Test
    public void test02() {
        loginService.weixinLogin("loginService");
    }

    @Test
    public void getStudentHelpAllList(){
        List<StudentCategoryHelpVo> studentCategoryHelpVoList = studentCategoryHelpVoService.getStudentCategoryHelpVoList();

//        List<Address> addresses = addressService.selectAddressList();
        System.out.println(studentCategoryHelpVoList);
    }


    public static void main(String[] args) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date now = new Date(); // 获取当前日期和时间
        String formattedDate = dateFormat.format(now);
        System.out.println(formattedDate);


        Address address1 = new Address();
        Address address2 = new Address();
        Address address3 = new Address();
        Address address4 = new Address();
        Address address5 = new Address();
        address3.setIsDefault(1);
        List<Address> addressList = new ArrayList<>();
        addressList.add(address1);
        addressList.add(address2);
        addressList.add(address3);
        addressList.add(address4);
        addressList.add(address5);
        System.out.println("list排序前：");
        for (Address address : addressList) {
            System.out.println(address);
        }

        Comparator<Address> addressComparator = Comparator.comparing(Address::getIsDefault).thenComparing(Address::getUpdateTime);
        addressList.sort(addressComparator);
        System.out.println("list排序后：");
        for (Address address : addressList) {
            System.out.println(address);
        }

    }



}
